'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  const jwtErr = app.middleware.jwtErr(app.config.jwt);

  router.get('/', controller.home.index);

  router.get('/article/lists', controller.article.lists);

  // router.post('/article/create', jwtErr, controller.article.create);
  // router.get('/article/detail/:id', jwtErr, controller.article.detail);
  // router.get('/article/detail/:id/posts', jwtErr, controller.article.posts);
  // router.get('/article/post/:id', jwtErr, controller.article.DetailPosts);
  // router.patch('/article/post/:id', jwtErr, controller.article.updatePost);
  // router.delete('/article/post/:id', jwtErr, controller.article.deletePosts);

  router.post('/article/create', controller.article.create);
  router.get('/article/detail/:id', controller.article.detail);
  router.get('/article/detail/:id/posts', controller.article.posts);
  router.get('/article/post/:id', controller.article.DetailPosts);
  router.patch('/article/post/:id', controller.article.updatePost);
  router.delete('/article/post/:id', controller.article.deletePosts);

  router.post('/user/register', controller.user.register);
  router.post('/user/login', controller.user.login);
  // router.post('/user/userInfo', jwtErr, controller.user.userInfo);
  router.post('/user/userInfo', controller.user.userInfo);

  router.post('/upload', controller.upload.uploadFiles);
};
